<?php

class RestitutionZoneDao {

    var $connection;

    function RestitutionZoneDao($connection) {
        $this->connection = $connection;
    }

    public function create($operator, $ZAR_param, $ZAR_reference,$ZAR_actif) {
        $sql = "INSERT INTO t_zone_autorisee_restitution_zar(ZAR_operateur,ZAR_param, ZAR_reference, ZAR_actif) VALUES(\"$operator\", \"$ZAR_param\",  \"$ZAR_reference\",1)";
        return $this->connection->query($sql);
    }

     public function update($ZAR_id, $ZAR_param, $ZAR_reference,$ZAR_actif) {
        $sql = "UPDATE  t_zone_autorisee_restitution_zar SET ZAR_reference=\"$ZAR_reference\", ZAR_param=\"$ZAR_param\", ZAR_actif=\"$ZAR_actif\"  where ZAR_id=$ZAR_id";
        return $this->connection->query($sql);
    }
    
    
    
    public function getZonesByOperator($operator) {
        $sql = "SELECT * FROM t_zone_autorisee_restitution_zar WHERE ZAR_operateur= \"$operator\"";
        $r = $this->connection->queryAll($sql); 
        return $r;
    }

    public function findall() {
        return $this->connection->queryAll("SELECT * FROM t_zone_autorisee_restitution_zar");
    }

}
